<?PHP

session_start();
include_once "php/ini.php";
dbconnect();

if ( isset ($_POST["deco"]))
{
	 $query = "UPDATE `users` SET `online` = '0' WHERE `users`.`id_user` = '".$_SESSION['id_user']."' LIMIT 1 ;";
                    $result = mysql_query($query);
                    if (!$result)
                    {
                        echo "SQL error : ", $query;
                        exit ;
                    }
    setcookie("goldname", $_SESSION["login"], time()-10);
    unset ($_SESSION["login"]);
    unset ($_SESSION["id_user"]);
	
}
elseif ( isset ($_COOKIE["goldname"]))
{
    $_SESSION["login"] = $_COOKIE["goldname"];
	 echo '<script language="Javascript">

document.location.replace("'.$url.'main.php");

</script>';
}
dbclose();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
        <title>Last Life</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      
        <script type="text/javascript" language="javascript" src="./js/jquery-1.3.2.min.js">
        </script>
        <script type="text/javascript" language="javascript" src="./js/function.js">
        </script>
        <script type="text/javascript" src="./ajaxfileupload/ajaxfileupload.js"></script>
                
    </head>
    <body>
  
        <div class="b_line">
            <div class="t1">
            	<?PHP
				include "./php/url.php";
                echo '<span class="l1"><a href="'.$url.'" title="Accueil">Last Life</a></span>'; ?>
            </div>
        </div>
        <div id="content">
            <?PHP
            //----------------- menu2 -------------------------------------------/
            function set_menu2()
            {
                $menu = "<div>
            	    		<ul>
            	    			<li class=\"l2\"><a href='?status=new'>Nouveau compte</a></li>
            	    			<li class=\"l2\"><a href='?status=pass'>Mot de passe oubli&eacute;</a></li>
            	    		</ul>
                		</div>";
            
                return $menu;
            }
            function formulaire_login()
            {
            //input type hiden value = lien $_get
			$redirect = (isset($_GET['id']))?"main.php?id=".$_GET['id']:"main.php";
                echo "<form method='POST' action='".$redirect."'>
                		<fieldset> <legend>Identification</legend>
                		<table><tr><td>Identifiant :</td><td> <input type='text' id='login' name='login' size='15'></td></tr>
                		<tr><td>Mot de Passe :</td><td><input type='password' id='pass' name='pass' size='15'></td></tr>
                		<tr><td colspan='2'><input type='checkbox' name='remember'>Se souvenir de moi</td></tr>
                		<tr><td><input type='submit' value='Connexion' name='connexion' ></td></tr>
                		</table>
                		</fieldset></form>";
            
                $menu = set_menu2();
                echo $menu;
				echo '<OBJECT id="virtool" style=" position: relative; float: left;" CLASSID="CLSID:D4323BF2-006A-4440-A2F5-27E3E7AB25F8" ID="Virtools" WIDTH="640" HEIGHT="480" CODEBASE="http://a532.g.akamai.net/f/532/6712/5m/virtools.download.akamai.com/6712/player/install/installer.exe#Version=4,0,0,26">
                <PARAM NAME="SRC" VALUE="testWebCam.vmo">
				 <param name="KeepKeyBoard" value="0">
                <EMBED SRC="testWebCam.vmo" TYPE="application/x-virtools" PLUGINSPAGE="http://player.virtools.com/" WIDTH="640" HEIGHT="480" NAME="Virtools" KeepKeyBoard="0">
                </EMBED>
            </OBJECT>'; 
            }
            
            
            if ( isset ($_GET["status"]))
            {
                if ($_GET['status'] == "new")
                {
                    echo "<fieldset id='new_compte'><legend>Nouveau compte</legend><br /><form onsubmit='f_save_compte(); return false;'>
                                      	<table><tr><td>Identifiant :</td><td> <input type='text' id='login' size='15' onBlur='f_verif_form(\"login\")' /></td></tr>
                                       	<tr><td>Mot de Passe :</td><td><input type='text' id='pass' size='15' onBlur='f_verif_form(\"pass\")' /></td></tr>
                                      	<tr><td>Email :</td><td><input type='text' id='mail' size='15' onBlur='f_verif_form(\"mail\")' /></td></tr>
                                      	<tr><td colspan='2'><input type='submit' value='Enregistrer' /></td></tr>
                                       	</table></form></fieldset>";
									
                }
                else
                {
                    echo "<form onsubmit='f_sendPassMail(); return false;'>
                                                   <fieldset id='id_mail'> <legend>Mot de passe oubli&eacute;</legend>
                                                    <table><tr><td>Email :</td><td> <input type='text' id='email' size='20' /></td></tr>
                                                    <tr><td colspan='2'><input type='submit' value='Envoyer' /></td></tr>
                                                   	</table></fieldset></form>";
								
                }
            
                //------------------------ menu2 --------------------------------------//
                $menu = set_menu2();
                echo $menu;
            
            
            }
            else
            {
                formulaire_login();
			}
            
            ?>
        </div>
		
		
      </body>
</html>
